//
//  LoginViewController.m
//  CommunityNannyO2O
//
//  Created by 90 on 15/7/21.
//  Copyright (c) 2015年 Apple. All rights reserved.
//

#import "LoginViewController.h"
#import "AppConfig.h"
#import "QXNetWorkTool.h"
#import "APIAdress.h"
#import "MBProgressHUD+YC.h"
#import "MJExtension.h"
#import "AccountTool.h"
#import "UIViewController+Create.h"
#import "LoginTableViewCell.h"
#import "FindPasswordViewController.h"
#import "registViewController.h"
#import "FindPasswordViewController.h"
#import "QXNetWorkTool.h"
#import "APIAdress.h"

@interface LoginViewController()<QXNetWorkToolDelegate,
                            UITableViewDataSource,UITableViewDelegate,
                LoginDeletage,RegistDeletage,ForgetPasswordDeletage,QXNetWorkToolDelegate>
{

}

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end


@implementation LoginViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self configNavigationItem];
    
    self.tableView.dataSource = self;
    
    self.tableView.delegate = self;
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 586;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    LoginTableViewCell *cell = [LoginTableViewCell cellWithTableView:tableView];
    cell.loginDeletage = self;
    cell.registDeletage = self;
    cell.forgetPasswordDeletage = self;
    
    return cell;
}

-(void)login
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)regist
{
    [self.navigationController pushViewController:
     [registViewController create] animated:YES];
}

-(void)forgetPassword
{
    [self.navigationController pushViewController:
     [FindPasswordViewController create] animated:YES];
}

-(void)back
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)configNavigationItem
{
    
//    [self.navigationController.navigationBar
//     setBackgroundImage:[UIImage imageNamed:@"bg_navigation_bar_green"]
//     forBarMetrics:UIBarMetricsDefault];
//    
//    //status bar的字体为白色
//    //导航栏的背景色是黑色
//    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
//    
//    [self configNavigationLeftItemWith:nil andAction:^{}];
//
////    [self configNavigationLeftString:@"11" textFont:[UIFont systemFontOfSize:12] andAction:^{
////    }];
//    
//    [self configNavigationBackAction:^{
//        
//        [self dismissViewControllerAnimated:YES completion:nil];
//    }];
    
        self.navigationController.navigationBar.hidden = YES;
}

-(void)useMethodToFindBlackLineAndHind
{
    UIImageView* blackLineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
    
    blackLineImageView.hidden = YES;
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [self configNavigationItem];

    [self useMethodToFindBlackLineAndHind];
}


-(void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController.navigationBar
     setBackgroundImage:[UIImage imageNamed:@"bg_navigation_bar"]
     forBarMetrics:UIBarMetricsDefault];
    
    self.navigationController.navigationBar.hidden = NO;
}


@end

















